package lk.service.impl;


import lk.service.LoginService;
import lk.util.PasswordUtil;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * author lk
 *
 * @date 2021/10/27 11:32
 * @description TODO
 * @since 1.0
 */
@Service
public class LoginServiceImpl implements LoginService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        ArrayList<GrantedAuthority> authorities = new ArrayList<>();

        authorities.add(new SimpleGrantedAuthority("/test1"));
        String admin = PasswordUtil.encryptionPassword("admin");

        return new User(username, admin, authorities);
    }
}
